package com.cpd.blog.controller;

import com.cpd.blog.dto.Article.CommentParam;
import com.cpd.blog.dto.Result;
import com.cpd.blog.service.CommentsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 评论接口
 *
 * @author Copydown
 * @date 2021/8/17 22:00
 */
@Api(tags = "文章评论模块")
@RestController
@RequestMapping("comments")
@RequiredArgsConstructor
public class CommentsController {

    private final CommentsService commentsService;

    @ApiOperation("搜索评论 接口")
    @GetMapping("article/{id}")
    public Result comments(@PathVariable("id") Long articleId) {
        return commentsService.commentByArticleId(articleId);
    }

    @ApiOperation("发表评论 接口")
    @PostMapping("create/change")
    public Result comment(@RequestBody CommentParam commentParam) {
        return commentsService.comment(commentParam);
    }
}
